<template>
  <div class="card" @click="goTo">
    <span :class="['card__icon','fa', 'fa-' + menu.img]" aria-hidden="true"></span>
    <h3 class="card__title">{{info.title}}</h3>
    <p class="card__body">
      {{body}}
    </p>
  </div>
</template>
<script>
  import getInfo from '~/config/head';

  export default {
    name: 's-small-card',
    data () {
      return {
        info: '',
      };
    },
    computed: {
      body () {
        if (this.info === '') return;
        for (let item of this.info.meta) {
          if (item.name === 'description') {
            return item.content;
          }
        }
      },
    },
    props: {
      menu: {
        type: Object,
        require: true,
      },
    },
    methods: {
      getInfo,
      goTo () {
        this.$parent.$router.push(this.menu.navigateUrl);
      },
    },
    mounted () {
      this.info = this.getInfo(this.menu.menuCode);
    },
  };
</script>

<style scoped lang="scss">
  .card {
    float: left;
    border-radius: 3px;
    box-shadow: 0 2px 10px 1px rgba(0, 0, 0, .1);
    height: 110px;
    width: 300px;
    margin: 15px;
    padding: 25px;
    position: relative;
    vertical-align: top;
    transition: .4s;
    cursor: pointer;
    &:hover {
      box-shadow: 0 10px 20px 1px rgba(0, 0, 0, .1);
      text-decoration: none;
    }
  }

  .card__icon {
    font-size: 24px;
    left: 28px;
    position: absolute;
    top: 25px;
    color: #20a0ff;
  }

  .card__title {
    color: #20a0ff;
    margin-top: 0;
    margin-bottom: 10px;
    margin-left: 40px;
  }

  .card__body {
    line-height: 22px;
    margin-left: 40px;
  }

  @media screen and (max-width: 800px) {
    .card {
      width: calc(100% - 80px);
    }
  }
</style>
